/**
 * 功能描述
 */
define(function (require, exports, module) {
	var Component = require("grid");
	var aw = require("ajaxwrapper");
	var Dialog = require("dialog");
	var store =require("store");
	var activeUser = store.get("user");
	var Form = require("form");
	var proctrgrid = require("../constant/fetchProperties");
	
    var instance = {
        initComponent: function (params, widget) {
            var grid = new Component({
            	parentNode : ".J-grid",	
            	url : "api/cate/travelaccount/query",
            	autoRender : false,
				params : function(){
					var subnav = widget.get("subnav");
					var obj = {
                			"servicePoint" : subnav.getValue("servicePoint"),
                			"status" : subnav.getValue("status"),
                			"creatDate" : subnav.getValue("grantDate").start,
                			"creatDateEnd" : subnav.getValue("grantDate").end,
                			"orderString" : "creatDate:desc",
                			"accountType":"Consumer",
                			fetchProperties : proctrgrid.fetchProperties
                	};
	    			return obj;
				},
				model : {
				 columns  : [{
					 name : "roomPersonalInfo.consumeCard.cardNumber",//
					 label : "卡号",
					 format: function(value, data){
						 if(data.status.key == "Returned"){
							 return "";
						 }else{
							 return value;
						 }
					 }
				 },{
					 name : "roomPersonalInfo.personalInfo.name",
					 label : "姓名",
				 },{
					 name : "roomPersonalInfo.personalInfo.idNumber",
					 label : "证件号",
				 },{
					 name : "roomPersonalInfo.personalInfo.mobilePhone",
					 label : "联系电话",
					 format: function(value, data){
						 if(value){
							 return value;
						 }else{
							 return data.roomPersonalInfo.personalInfo.phone
						 }
					 }
				 },{
					 name : "balance",
					 label : "余额(元)",
					 format: function(value){
						 if(value){
							 return parseFloat(value).toFixed(2);
						 }else{
							 return "0";
						 }
					 }
				 },{
					 name : "creatDate",
					 label : "发放日期",
					 format : "date",
				 },{
					 name : "status.value",
					 label : "状态",
				 },{
					name:"operate",
					label:"操作",
					format:"button",
					formatparams:[{
						id:"recharge",
						icon:"icon-edit",
						text:"充值",
						show: function(value,data){
    						if(data.status.key == "Effective"){
    							return true;
    						}else{
    							return false;
    						}
    					},
						handler:function(index,data,rowEle){
							widget.handler.gridHandler.gridRecharge(data,widget);
						}
					},{
						id:"gs",
						icon:"icon-edit",
						text:"挂失",
						show: function(value,data){
							if(data.status.key == "Effective"){
    							return true;
    						}else{
    							return false;
    						}
        				},
						handler:function(index,data,rowEle){
							widget.handler.gridHandler.gridGs(data,widget);
						}
					},{
						id:"tk",
						icon:"icon-edit",
						text:"退卡",
						show: function(value,data){
							if(data.status.key == "Effective"){
    							return true;
    						}else{
    							return false;
    						}
        				},
						handler:function(index,data,rowEle){
							widget.handler.gridHandler.gridTk(data,widget);
						}
					},{
						id:"bb",
						icon:"icon-edit",
						text:"补办",
						show: function(value,data){
    						if(data.status.key == "Lose"){
    							return true;
    						}else{
    							return false;
    						}
        				},
						handler:function(index,data,rowEle){
							widget.handler.gridHandler.gridBb(data,widget);
						}
					},{
						id:"detail",
						icon:"icon-edit",
						text:"明细",
						handler:function(index,data,rowEle){
							widget.handler.gridHandler.gridMx(data,widget);
						}
					}]
				 }]
				}
            });
            widget.set("grid", grid);
        }
    };
    module.exports = instance;
});
